import { createSlice, PayloadAction } from '@reduxjs/toolkit';

interface IState {
  count: number;
  message: string;
  num: number;
  direction: 'left' | 'right' | 'up' | 'down';
}

const initialState: IState = {
  count: 100,
  message: 'hello world',
  num: 100,
  direction: 'right'
};

const counterSlice = createSlice({
  name: 'counter',
  initialState: initialState,
  reducers: {
    changeMessageAction(state, { payload }: PayloadAction<string>) {
      state.message = payload;
      // return {
      //   ...state,
      //   message: paylaod
      // };
    }
  }
});

export const { changeMessageAction } = counterSlice.actions;

export default counterSlice.reducer;
